home *** CD-ROM | disk | FTP | other *** search
/ PC World 2007 December / PCWorld_2007-12_cd.bin / v cisle / htttrack / httrack-3.41-3.exe / {app} / src_win / WinHTTrack / WinHTTrackDoc.cpp < prev    next >
C/C++ Source or Header  |  2006-10-01  |  5KB  |  194 lines

  1. // WinHTTrackDoc.cpp : implementation of the CWinHTTrackDoc class
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "WinHTTrack.h"
  6.  
  7. #include "WinHTTrackDoc.h"
  8.  
  9. #ifdef _DEBUG
  10. #define new DEBUG_NEW
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14.  
  15. extern "C" {
  16.   #include "HTTrackInterface.h"
  17. }
  18.  
  19. /* dialog0 */
  20. #include "NewProj.h"
  21. extern CNewProj* dialog0;
  22.  
  23. /* Main WizTab frame */
  24. #include "WizTab.h"
  25. extern CWizTab* this_CWizTab;
  26.  
  27. // dirtreeview
  28. #include "DirTreeView.h"
  29. extern CDirTreeView* this_DirTreeView;
  30.  
  31. /////////////////////////////////////////////////////////////////////////////
  32. // CWinHTTrackDoc
  33.  
  34. IMPLEMENT_DYNCREATE(CWinHTTrackDoc, CDocument)
  35.  
  36. BEGIN_MESSAGE_MAP(CWinHTTrackDoc, CDocument)
  37.     //{{AFX_MSG_MAP(CWinHTTrackDoc)
  38.         // NOTE - the ClassWizard will add and remove mapping macros here.
  39.         //    DO NOT EDIT what you see in these blocks of generated code!
  40.     //}}AFX_MSG_MAP
  41. END_MESSAGE_MAP()
  42.  
  43. /////////////////////////////////////////////////////////////////////////////
  44. // CWinHTTrackDoc construction/destruction
  45.  
  46. CWinHTTrackDoc::CWinHTTrackDoc()
  47. {
  48.     // TODO: add one-time construction code here
  49.  
  50. }
  51.  
  52. CWinHTTrackDoc::~CWinHTTrackDoc()
  53. {
  54. }
  55.  
  56. BOOL CWinHTTrackDoc::OnNewDocument()
  57. {
  58.     if (!CDocument::OnNewDocument())
  59.         return FALSE;
  60.  
  61.     // TODO: add reinitialization code here
  62.     // (SDI documents will reuse this document)
  63.  
  64.     return TRUE;
  65. }
  66.  
  67.  
  68.  
  69. /////////////////////////////////////////////////////////////////////////////
  70. // CWinHTTrackDoc serialization
  71.  
  72. void CWinHTTrackDoc::Serialize(CArchive& ar)
  73. {
  74.     if (ar.IsStoring())
  75.     {
  76.         // TODO: add storing code here
  77.     }
  78.     else
  79.     {
  80.         // TODO: add loading code here
  81.     }
  82. }
  83.  
  84. /////////////////////////////////////////////////////////////////////////////
  85. // CWinHTTrackDoc diagnostics
  86.  
  87. #ifdef _DEBUG
  88. void CWinHTTrackDoc::AssertValid() const
  89. {
  90.     CDocument::AssertValid();
  91. }
  92.  
  93. void CWinHTTrackDoc::Dump(CDumpContext& dc) const
  94. {
  95.     CDocument::Dump(dc);
  96. }
  97. #endif //_DEBUG
  98.  
  99. /////////////////////////////////////////////////////////////////////////////
  100. // CWinHTTrackDoc commands
  101.  
  102. BOOL CWinHTTrackDoc::OnSaveDocument(LPCTSTR lpszPathName) 
  103. {
  104.     // TODO: Add your specialized code here and/or call the base class
  105.     
  106.     //return CDocument::OnSaveDocument(lpszPathName);
  107.   //AfxMessageBox(lpszPathName);
  108.  
  109.   if (dialog0) {
  110.     CString PathName=lpszPathName;
  111.     int pos=PathName.ReverseFind('.');
  112.     if (pos>=0) {
  113.       if (PathName.Mid(pos)==".whtt") {
  114.         if (dialog0->GetPath0()+".whtt" != LPCSTR(lpszPathName)) {
  115.           switch(AfxMessageBox(LANG_G26b,MB_YESNOCANCEL)) {
  116.           case IDYES:
  117.             {
  118.               CString path=lpszPathName;
  119.               int pos=path.ReverseFind('.');
  120.               if (pos>=0) {
  121.                 CString dir=path.Left(pos);           // enlever .whtt
  122.                 pos=path.ReverseFind('\\');
  123.                 dialog0->m_projname=dir.Mid(pos+1);
  124.                 dialog0->m_projpath=dir.Left(pos);
  125.               }
  126.             }
  127.             break;
  128.           case IDNO:
  129.             break;
  130.           default:
  131.             return 0;
  132.             break;
  133.           }
  134.         }
  135.       }
  136.     }
  137.     
  138.     Save_current_profile(0);
  139.   }
  140.  
  141.   return 1;
  142. }
  143.  
  144. BOOL CWinHTTrackDoc::OnOpenDocument(LPCTSTR lpszPathName) 
  145. {
  146.     /*if (!CDocument::OnOpenDocument(lpszPathName))
  147.         return FALSE;
  148.     */
  149.   CFileStatus status;
  150.   if (CFile::GetStatus(lpszPathName,status)) {
  151.     CString PathName=lpszPathName;
  152.  
  153.     /* si rΘpertoire, convertir d'abord en .whtt */
  154.     if (status.m_attribute & 0x10 ) {       /* directory = 0x10 */
  155.       PathName+=".whtt";
  156.     }
  157.     
  158.     int pos=PathName.ReverseFind('.');
  159.     if (pos>=0) {
  160.       if (PathName.Mid(pos)==".whtt") {
  161.         CString dir=PathName.Left(pos)+"\\";
  162.         CString profile=dir+"hts-cache\\winprofile.ini";    
  163.         Read_profile((char*) LPCTSTR(profile),1);
  164.         //if (fexist((char*) LPCTSTR(profile))) {
  165.         //} else {
  166.           //AfxMessageBox(LANG(LANG_G26 /*"File not found!","Fichier introuvable!"*/));
  167.           /*return FALSE;*/
  168.         //}
  169.         if (dialog0->m_projname.GetLength() > 0) {
  170.           this_CWizTab->PressButton(PSBTN_NEXT);
  171.           this_CWizTab->PressButton(PSBTN_NEXT);
  172.         }
  173.       } else {
  174.         AfxMessageBox(LANG(LANG_G26 /*"File not found!","Fichier introuvable!"*/));
  175.         return FALSE;
  176.       }
  177.     } else {
  178.       AfxMessageBox(LANG(LANG_G26 /*"File not found!","Fichier introuvable!"*/));
  179.       return FALSE;
  180.     }
  181.   } else {
  182.     AfxMessageBox(LANG(LANG_G26 /*"File not found!","Fichier introuvable!"*/));
  183.     return FALSE;
  184.   }
  185.   
  186.   return TRUE;
  187. }
  188.  
  189. void CWinHTTrackDoc::OnCloseDocument() 
  190. {
  191.     // TODO: Add your specialized code here and/or call the base class
  192.     CDocument::OnCloseDocument();
  193. }
  194.